package com.itheima.stock.controal;

import com.itheima.stock.UserService;
import com.itheima.stock.pojo.entity.SysUser;
import com.itheima.stock.vo.rep.LoginReqVo;
import com.itheima.stock.vo.resp.LoginRespVo;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/user/{username}")
    public SysUser getUserByUsername(@PathVariable String username){
        SysUser finuserinfobyusername = userService.finuserinfobyusername(username);
        System.out.println(finuserinfobyusername);
        return finuserinfobyusername;
    }
    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){
        R<LoginRespVo> r= this.userService.login(vo);
        return r;
    }
}
